//
//  ViewController.m
//  01_拉勾
//
//  Created by dllo on 16/7/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "AccountView.h"

@interface ViewController ()
@property (nonatomic, strong) AccountView *userNameView;
@property (nonatomic, strong) AccountView *passwordView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *visualView = [[UIVisualEffectView alloc] initWithEffect: blur];
    visualView.frame = self.view.frame;
    [self.view addSubview:visualView];
    visualView.alpha = 0.8;
    
    UIImageView *welcomeImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    welcomeImageView.image = [UIImage imageNamed:@"welcome_2"];
    [self.view addSubview:welcomeImageView];
    
    UIImageView *lagouImageView = [[UIImageView alloc] initWithFrame:CGRectMake(147, 161, 120, 185)];
    lagouImageView.image = [UIImage imageNamed:@"logo_lagou"];
    [self.view addSubview:lagouImageView];

    self.userNameView = [[AccountView alloc] initWithFrame:CGRectMake(12, 372, 390, 42) image:[UIImage imageNamed:@"icon_username"]];
    UIBezierPath *userMaskPath = [UIBezierPath bezierPathWithRoundedRect:self.userNameView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(5, 5)];
    CAShapeLayer *userMaskLayer = [[CAShapeLayer alloc] init];
    userMaskLayer.frame = self.userNameView.bounds;
    userMaskLayer.path = userMaskPath.CGPath;
    self.userNameView.layer.mask = userMaskLayer;
    [self.view addSubview:self.userNameView];
    
    self.passwordView = [[AccountView alloc] initWithFrame:CGRectMake(12, 416, 390, 42) image:[UIImage imageNamed:@"icon_password"]];
    UIBezierPath *passwordMaskPath = [UIBezierPath bezierPathWithRoundedRect:self.userNameView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];
    CAShapeLayer *passwordMaskLayer = [[CAShapeLayer alloc] init];
    passwordMaskLayer.frame = self.passwordView.bounds;
    passwordMaskLayer.path = passwordMaskPath.CGPath;
    self.passwordView.layer.mask = passwordMaskLayer;
    [self.view addSubview:self.passwordView];

    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    loginButton.backgroundColor = [UIColor colorWithRed:57 / 255.0f green:159 / 255.0f blue:114 / 255.0f alpha:1];
    [loginButton setTitle:@"登录" forState:UIControlStateNormal];
    [loginButton setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    loginButton.frame = CGRectMake(12, 481, 391, 43);
    [self.view addSubview:loginButton];
    [loginButton addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *forgetButton = [UIButton buttonWithType:UIButtonTypeSystem];
    forgetButton.backgroundColor = [UIColor clearColor];
    [forgetButton setTitle:@"忘记密码" forState:UIControlStateNormal];
    [forgetButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    forgetButton.frame = CGRectMake(12, 549, 71, 21);
    [self.view addSubview:forgetButton];
    
    UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    registerButton.backgroundColor = [UIColor clearColor];
    [registerButton setTitle:@"现在注册拉勾" forState:UIControlStateNormal];
    [registerButton setTitleColor:[UIColor colorWithRed:0 green:161 / 255.0f blue:123 / 255.0f alpha:1] forState:UIControlStateNormal];
    registerButton.frame = CGRectMake(149, 601, 116, 22);
    [self.view addSubview:registerButton];
    
    UIView *lineOrLeftView = [[UIView alloc] initWithFrame:CGRectMake(12, 653, 172, 1)];
    lineOrLeftView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:lineOrLeftView];
    
    UIView *lineOrRightView = [[UIView alloc] initWithFrame:CGRectMake(232, 653, 172, 1)];
    lineOrRightView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:lineOrRightView];
    
    UILabel *orLabel = [[UILabel alloc] initWithFrame:CGRectMake(200, 643, 23, 19)];
    orLabel.backgroundColor = [UIColor clearColor];
    orLabel.text = @"or";
    orLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:orLabel];
    
    UIButton *guangguangButton = [UIButton buttonWithType:UIButtonTypeSystem];
    guangguangButton.backgroundColor = [UIColor clearColor];
    [guangguangButton setTitle:@"随便逛逛>" forState:UIControlStateNormal];
    [guangguangButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    guangguangButton.frame = CGRectMake(167, 677, 81, 22);
    [self.view addSubview:guangguangButton];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self.view addGestureRecognizer:tap];
}

- (void)tapAction:(UITapGestureRecognizer *)tap {
    UITextField *textField1 = self.userNameView.subviews[1];
    [textField1 resignFirstResponder];
    UITextField *textField2 = self.passwordView.subviews[1];
    [textField2 resignFirstResponder];
}

- (void)login {
    NSLog(@"打打试试的");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
